package com.qishon.pc.domain.Controller;

import com.qishon.pc.domain.Application.PreViewManager;
import com.qishon.pc.domain.model.MasPartHd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by xm on 2016/12/23.
 */
@Controller
public class MainController {

    @Autowired
    private PreViewManager preViewManager;

    @GetMapping("/")
    public String welcome(Map<String, Object> map, Model model) {
        model.addAttribute("progressControls", "test");
        return "index";
    }

    @ResponseBody
    @RequestMapping("/previewJson")
    public MasPartHd findMasPartByPartCode(@RequestParam Map<String, Object> map, Model model) {
        return preViewManager.findMasPartByPartCode(map);
    }

    @RequestMapping("/preview")
    public String showPreview(@RequestParam Map<String, Object> map, Model model) {
        model.addAttribute("partCode", map.get("partCode"));
        return "preview";
    }

    @RequestMapping("/img")
    public String getImg(@RequestParam Map<String, Object> map, Model model) {
        model.addAttribute("partCode", map.get("partCode"));
        return "preview";
    }

}
